package com.malty.mall.domain.entity.ums;


import com.baomidou.mybatisplus.annotation.TableName;
import com.malty.mall.domain.dto.req.UmsResourceTypeParam;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author malty
 */
@Data
@NoArgsConstructor
@TableName("ums_resource_type")
public class UmsResourceType {
    private Integer id;
    private String typeName;
    private Integer sort;
    private Date createTime;
    private Date updateTime;

    public UmsResourceType(UmsResourceTypeParam umsResourceTypeParam) {
        this.typeName = umsResourceTypeParam.getTypeName();
        this.sort = umsResourceTypeParam.getSort();
    }

    public static List<UmsResourceTypeParam> getParamBatch(List<UmsResourceType> resourceTypes) {
        List<UmsResourceTypeParam> resourceTypeParams = new ArrayList<>();
        for (UmsResourceType resourceType : resourceTypes) {
            resourceTypeParams.add(new UmsResourceTypeParam(resourceType));
        }
        return resourceTypeParams;
    }
}
